perm filename DIALU.MID[DLN,MRC] blob sn#301702 filedate 1977-08-15 generic text, type C, neo UTF8
COMMENT āŠ—   VALID 00007 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	title DIALU
C00003 00003	Initialization
C00006 00004	Flush connection
C00007 00005	Subroutines
C00009 00006	 LOGSTR writes a string to the log file.
C00010 00007	Errors
C00012 ENDMK
CāŠ—;
title DIALU

; Experimental DIALnet user for experimentation with protocols.

dibf:	block 3
dobf:	block 3
lobf:	block 3

dialbk:	2				; dial
	0				; no area code

radix 10.
.byte 8,4,4,4,4,4,4,4

	0
	4 ? 9 ? 3 ? 5 ? 5 ? 0 ? 5	; TTY-10 @ SAIL

.byte
radix 8
subttl Initialization

dialu:	jfcl
	reset
	open 1,[0 ? 'DSK,, ? lobf,,]
	 jrst 4,.-1
	enter 1,[sixbit/DIALU LOG/ ? 0 ? 'DLNMRC]
	 jrst [	outstr [asciz/Can't write log file./]
		jrst 4,.-1]
	jsp 1,logmsg
	 asciz/DIALU started./
	outstr [asciz/Trying... /]
	jsp 1,logmsg
	 asciz/Attempting to access dialer./
	open [0 ? sixbit/TTY11/ ? dibf ? dobf]
	 jrst [	outstr [asciz/Somebody has TTY11 right now./]
		jsp 1,logmsg
		 asciz/Unable to access dialer./
		jrst punt]
	jsp 1,logmsg
	 asciz/Attempting to claim dialer./
	movei 1,[0]
	dial 1,				; claim dialer
	 jrst dialuz
	jsp 1,logmsg
	 asciz/Attempting to dial /
	move 2,[340400,,dialbk+2]
repeat 3,[				; exchange
	 ildb 2
	 addi "0
	 jsr logchr
]
	movei "-
	jsr logchr
repeat 4,[				; number
	 ildb 2
	 addi "0
	 jsr logchr
]
	movei ".
	jsr logchr
	movei 1,dialbk
	dial 1,				; call up ourselves
	 jrst dialuz
	movei 10.			; try 10. times for connection
contry:	movei 1,[1]
	dial 1,				; get dialer status
	 jrst dialuz
	tlne 1,4000			; got connection?
	 jrst gotcon
	sojge contry
	jrst conluz

; Connection won.

gotcon:	movem 1,dlconi'
	jsp 1,logmsg
	 asciz/Connection established, PI channel=/
	outstr [asciz/Open.  PI channel=/]
	move 1,dlconi
	andi 1,7			; only PI channel
	movei "0(1)			; convert to ASCII
	jsr logchr
	outchr
	outstr [asciz/
/]
subttl Flush connection

byebye:	outstr [asciz/Disconnecting.../]
	jsp 1,logmsg
	 asciz/Trying to break connection./
	movei 1,[3]
	dial 1,				; hang up dialer's phone
	 jrst dialuz
	jsp 1,logmsg
	 asciz/Connection broken./

; Finish off

punt:	jsp 1,logmsg
	 asciz/End of DIALU run.
/
	close 1,			; terminate log file
	exit
subttl Subroutines

; LOGMSG writes a message with time stamp to the log file
;	jsp 1,logmsg
;	 asciz/string/
; clobbers 0,1,2,3,4
;  Sorry for the extreme in open-coding, but I'm in a hurry and this doesn't
; take all that much core and is more efficient anyway.

logmsg:	movei ↑M ? jsr logchr ? movei ↑J ? jsr logchr
	date 2,
	idivi 2,31.			; days
	movem 3,days'
	idivi 2,12.			; months
	movem 2,years'
	idivi 3,10.
	movei "0(3)
	jsr logchr
	movei "0(4)
	jsr logchr
	movei "/
	jsr logchr
	aos 2,days
	idivi 2,10.
	movei "0(2)
	jsr logchr
	movei "0(3)
	jsr logchr
	movei "/
	jsr logchr
	move 2,years
	addi 2,64.			; the world began on 1/1/64 in Maynard
	idivi 2,10.
	movei "0(2)
	jsr logchr
	movei "0(3)
	jsr logchr
	movei <" >
	jsr logchr
	mstime 2,
	idivi 2,1000.
	idivi 2,60.			; seconds
	movem 3,secs'
	idivi 2,60.			; minutes
	movem 3,mins'
	idivi 2,10.
	movei "0(2)
	jsr logchr
	movei "0(3)
	jsr logchr
	movei ":
	jsr logchr
	move 2,mins
	idivi 2,10.
	movei "0(2)
	jsr logchr
	movei "0(3)
	jsr logchr
	movei ":
	jsr logchr
	move 2,secs
	idivi 2,10.
	movei "0(2)
	jsr logchr
	movei "0(3)
	jsr logchr
	movei <" >
	jsr logchr
;	jrst logstr			; fall through
; LOGSTR writes a string to the log file.
;	jsp 1,logstr
;	 asciz/string/
; clobbers 0,1

logstr:	hrli 1,440700
	ildb 1
	jumpe 1(1)
	jsr logchr
	jrst logstr+1

; LOGCHR writes a character to the log file.
;	movei character
;	jsr logchr

logchr:	0
	sosg lobf+2
	 out 1,
	  caia
	   jrst 4,.-2
	idpb lobf+1
	jrst 2,@logchr
subttl Errors

; Connection lost

conluz:	outstr [asciz/Failed./]
	trne 1,2000
	 outstr [asciz/
Data set disconnect./]
	trne 1,1000
	 outstr [asciz/
Busy./]
	trne 1,400
	 outstr [asciz/
Data phone not hung./]
	trne 1,200
	 outstr [asciz/
Data set connected./]
	trne 1,40
	 outstr [asciz/
Voice call./]
	jsp 1,logmsg
	 asciz/Failed to get connection./
	jrst punt

; DIAL UUO lost

dialuz:	cail 1,
	 caile 1,4
	  jrst 4,.
	movem 1,foo'
	jsp 1,logmsg
	 asciz/Dialing error./
	move 1,foo'
	outstr @(1)[	[asciz/Illegal dialer number./]
			[asciz/Dialer in use./]
			[asciz/TTY11 not open./]
			[asciz/Attempted to dial while call in progress./]
			[asciz/Dialing failure./]]
	caie 1,4
	 jrst punt
	outstr [asciz/
Hanging up.  Try again./]
	jsp 1,logmsg
	 asciz/Trying to flush connection./
	movei 1,[3]
	dial 1,				; try to win by hanging up
	 jrst 4,.
	jsp 1,logmsg
	 asciz/Connection flushed./
	jrst punt

end dialu